import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/components/home.vue'
import Order from '@/components/order.vue'
import OrderList from '@/components/order/List.vue'
import OrderCreate from '@/components/order/Create.vue'
import OrderView from '@/components/order/View.vue'
import TransportCreate from '@/components/transport/Create.vue'
import ReceiptConfirm from '@/components/receipt/Confirm.vue'
import ReceiptDispatch from '@/components/receipt/Dispatch.vue'
import ReceiptOrder from '@/components/receipt/Order.vue'
import ExceptionCreate from '@/components/exception/Create.vue'
import ExceptionList from '@/components/exception/List.vue'
import FinanceReceivable from '@/components/finance/Receivable.vue'
import FinanceReconciliation from '@/components/finance/Reconciliation.vue'
import Login from '@/components/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home
  },
  {
    path: '/order',
    name: 'order',
    component: Order,
    children: [
      {
        path: 'list',
        name: 'orderList',
        component: OrderList
      },
      {
        path: 'create',
        name: 'orderCreate',
        component: OrderCreate
      },
      {
        path: 'view/:id',
        name: 'orderView',
        component: OrderView
      }
    ]
  },
  {
    path: '/transport',
    name: 'transport',
    component: { render: h => h('router-view') },
    children: [
      {
        path: 'create',
        name: 'transportCreate',
        component: TransportCreate
      }
    ]
  },
  {
    path: '/receipt',
    component: { render: h => h('router-view') },
    children: [
      {
        path: 'confirm',
        name: 'receiptConfirm',
        component: ReceiptConfirm
      },
      {
        path: 'dispatch',
        name: 'receiptDispatch',
        component: ReceiptDispatch
      },
      {
        path: 'order',
        name: 'receiptOrder',
        component: ReceiptOrder
      }
    ]
  },
  {
    path: '/exception',
    component: { render: h => h('router-view') },
    children: [
      {
        path: 'create',
        name: 'exceptionCreate',
        component: ExceptionCreate
      },
      {
        path: 'list',
        name: 'exceptionList',
        component: ExceptionList
      }
    ]
  },
  {
    path: '/finance',
    component: { render: h => h('router-view') },
    children: [
      {
        path: 'receivable',
        name: 'financeReceivable',
        component: FinanceReceivable
      },
      {
        path: 'reconciliation',
        name: 'financeReconciliation',
        component: FinanceReconciliation
      }
    ]
  },{
    path: '/login',
    name: 'login',
    component: Login
  }
]

const router = new VueRouter({
  routes
})

export default router
